/*
 * @Author: likaijie 847094299@qq.com
 * @Date: 2025-03-13 16:00:06
 * @LastEditors: likaijie 847094299@qq.com
 * @LastEditTime: 2025-04-02 14:33:25
 * @Description:
 */
import { http } from "@/utils/http";

export type UserResult = {
  success: boolean;
  data: {
    token: string;
    user: {
      createTime: string;
      deleted: number;
      id: number;
      password: string;
      updateTime: string;
      pointsBalance: number;
      role: string;
      status: string;
      username: string;
    };
  };
};

export type RefreshTokenResult = {
  success: boolean;
  data: {
    /** `token` */
    token: string;
    /** 用于调用刷新`accessToken`的接口时所需的`token` */
    refreshToken: string;
  };
};

/** 登录 */
export const getLogin = (data?: object) => {
  return http.request<UserResult>("post", "/api/auth/login", { data });
};

/** 刷新`token` */
export const refreshTokenApi = (data?: object) => {
  return http.request<RefreshTokenResult>("post", "/refresh-token", { data });
};
